home *** CD-ROM | disk | FTP | other *** search
- #define OLDROUTINELOCATIONS 0
- #define OLDROUTINENAMES 0
- #define SystemSevenOrLater 1
-
- #ifndef __FONTS__
- # include <Fonts.h>
- #endif
-
- #ifndef __DIALOGS__
- # include <Dialogs.h>
- #endif
-
- #ifndef __PRINTING__
- # include <Printing.h>
- #endif
-
- static TPPrDlgRef gTPPrDlgRef;
- static DialogRef gDialogRef;
-
- static pascal OSErr InitMac (void)
- {
- MaxApplZone ( );
- InitGraf (&(qd.thePort));
- InitFonts ( );
- InitWindows ( );
- InitMenus ( );
- TEInit ( );
- InitDialogs (nil);
- InitCursor ( );
-
- return noErr;
- }
-
- static pascal OSErr ReportError (OSErr)
- {
- SysBeep (-1);
- return noErr;
- }
-
- static pascal TPPrDlgRef PDlgInitProc (THPrint)
- {
- return gTPPrDlgRef;
- }
-
- static pascal Boolean ModalFilterProc
- (DialogPtr dialog, EventRecord *event, short *itemHit)
- {
- Boolean handledIt = false;
-
- if (gDialogRef == dialog)
- {
- if (event->what == nullEvent)
- {
- *itemHit = kStdOkItemIndex;
- handledIt = true;
- }
- }
-
- return handledIt;
- }
-
- void main (void)
- {
- OSErr err = InitMac ( );
-
- if (err)
- SysBeep (-1);
- else
- {
- THPrint printRecordH = (THPrint) NewHandle (sizeof (TPrint));
-
- if (!printRecordH)
- err = MemError ( );
- else
- {
- OSErr err2 = noErr;
-
- PrOpen ( );
-
- if (!(err = PrError ( )))
- {
- PrintDefault (printRecordH);
-
- if (!(err = PrError ( )))
- {
- TPPrDlgRef prDlg = PrJobInit (printRecordH);
-
- if (!(err = PrError ( )))
- {
- ModalFilterUPP modalFilterUPP = NewModalFilterProc (ModalFilterProc);
-
- if (!modalFilterUPP)
- err = nilHandleErr;
- else
- {
- PDlgInitUPP pDlgInitUPP = NewPDlgInitProc (PDlgInitProc);
-
- if (!pDlgInitUPP)
- err = nilHandleErr;
- else
- {
- Boolean userApprovedPrintJob;
- MoveWindow ((WindowRef) prDlg, -32000, -32000, false);
-
- prDlg->pFltrProc = modalFilterUPP;
-
- gTPPrDlgRef = prDlg;
- gDialogRef = (DialogRef) prDlg;
-
- userApprovedPrintJob = PrDlgMain (printRecordH,pDlgInitUPP);
- if (!(err = PrError ( )) && userApprovedPrintJob)
- {
- // do the rest of your printing here
- }
- DisposeRoutineDescriptor (pDlgInitUPP);
- }
- DisposeRoutineDescriptor (modalFilterUPP);
- }
- }
- }
-
- PrClose ( );
- err2 = PrError ( );
- if (!err) err = err2;
- }
-
- DisposeHandle ((Handle) printRecordH);
- err2 = MemError ( );
- if (!err) err = err2;
- }
-
- if (err)
- (void) ReportError (err);
- }
- }
-